
package cn.edu.scau.cmi.hombio.service;

import cn.edu.scau.cmi.hombio.domain.Employee;
import cn.edu.scau.cmi.hombio.domain.Task;
import cn.edu.scau.cmi.hombio.domain.TaskEmployee;

import java.util.List;
import java.util.Set;

import org.junit.Test;

import org.junit.runner.RunWith;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.beans.factory.support.DefaultListableBeanFactory;

import org.springframework.context.ApplicationContext;

import org.springframework.mock.web.MockHttpServletRequest;

import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestExecutionListeners;

import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import org.springframework.test.context.support.DependencyInjectionTestExecutionListener;
import org.springframework.test.context.support.DirtiesContextTestExecutionListener;

import org.springframework.test.context.transaction.TransactionalTestExecutionListener;

import org.springframework.transaction.annotation.Transactional;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.RequestScope;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.context.request.SessionScope;

/**
 * Class to run the service as a JUnit test. Each operation in the service is a separate test.
 *
 */

@RunWith(SpringJUnit4ClassRunner.class)
@TestExecutionListeners({
		DependencyInjectionTestExecutionListener.class,
		DirtiesContextTestExecutionListener.class,
		TransactionalTestExecutionListener.class })
@ContextConfiguration(locations = {
		"file:./resources/pigRs-security-context.xml",
		"file:./resources/pigRs-service-context.xml",
		"file:./resources/pigRs-dao-context.xml",
		"file:./resources/pigRs-web-context.xml" })
@Transactional
public class TaskEmployeeServiceTest {

	/**
	 * The Spring application context.
	 *
	 */
	@SuppressWarnings("unused")
	private ApplicationContext context;

	/**
	 * The service being tested, injected by Spring.
	 *
	 */
	@Autowired
	protected TaskEmployeeService service;

	/**
	 * Instantiates a new TaskEmployeeServiceTest.
	 *
	 */
	public TaskEmployeeServiceTest() {
		setupRequestContext();
	}

	/**
	 * Operation Unit Test
	* Delete an existing TaskEmployee entity
	* 
	 */
	@Test
	public void deleteTaskEmployee() {
		// TODO: JUnit - Populate test inputs for operation: deleteTaskEmployee 
		TaskEmployee taskemployee = new cn.edu.scau.cmi.hombio.domain.TaskEmployee();
		service.deleteTaskEmployee(taskemployee);
	}

	/**
	 * Operation Unit Test
	* Save an existing Task entity
	* 
	 */
	@Test
	public void saveTaskEmployeeTask() {
		// TODO: JUnit - Populate test inputs for operation: saveTaskEmployeeTask 
		Integer id = 0;
		Task related_task = new cn.edu.scau.cmi.hombio.domain.Task();
		TaskEmployee response = null;
		response = service.saveTaskEmployeeTask(id, related_task);
		// TODO: JUnit - Add assertions to test outputs of operation: saveTaskEmployeeTask
	}

	/**
	 * Operation Unit Test
	* Return all TaskEmployee entity
	* 
	 */
	@Test
	public void findAllTaskEmployees() {
		// TODO: JUnit - Populate test inputs for operation: findAllTaskEmployees 
		Integer startResult = 0;
		Integer maxRows = 0;
		List<TaskEmployee> response = null;
		response = service.findAllTaskEmployees(startResult, maxRows);
		// TODO: JUnit - Add assertions to test outputs of operation: findAllTaskEmployees
	}

	/**
	 * Operation Unit Test
	* Save an existing TaskEmployee entity
	* 
	 */
	@Test
	public void saveTaskEmployee() {
		// TODO: JUnit - Populate test inputs for operation: saveTaskEmployee 
		TaskEmployee taskemployee_1 = new cn.edu.scau.cmi.hombio.domain.TaskEmployee();
		service.saveTaskEmployee(taskemployee_1);
	}

	/**
	 * Operation Unit Test
	* Return a count of all TaskEmployee entity
	* 
	 */
	@Test
	public void countTaskEmployees() {
		Integer response = null;
		response = service.countTaskEmployees();
		// TODO: JUnit - Add assertions to test outputs of operation: countTaskEmployees
	}

	/**
	 * Operation Unit Test
	 */
	@Test
	public void findTaskEmployeeByPrimaryKey() {
		// TODO: JUnit - Populate test inputs for operation: findTaskEmployeeByPrimaryKey 
		Integer id_1 = 0;
		TaskEmployee response = null;
		response = service.findTaskEmployeeByPrimaryKey(id_1);
		// TODO: JUnit - Add assertions to test outputs of operation: findTaskEmployeeByPrimaryKey
	}

	/**
	 * Operation Unit Test
	* Load an existing TaskEmployee entity
	* 
	 */
	@Test
	public void loadTaskEmployees() {
		Set<TaskEmployee> response = null;
		response = service.loadTaskEmployees();
		// TODO: JUnit - Add assertions to test outputs of operation: loadTaskEmployees
	}

	/**
	 * Operation Unit Test
	* Save an existing Employee entity
	* 
	 */
	@Test
	public void saveTaskEmployeeEmployee() {
		// TODO: JUnit - Populate test inputs for operation: saveTaskEmployeeEmployee 
		Integer id_2 = 0;
		Employee related_employee = new cn.edu.scau.cmi.hombio.domain.Employee();
		TaskEmployee response = null;
		response = service.saveTaskEmployeeEmployee(id_2, related_employee);
		// TODO: JUnit - Add assertions to test outputs of operation: saveTaskEmployeeEmployee
	}

	/**
	 * Operation Unit Test
	* Delete an existing Task entity
	* 
	 */
	@Test
	public void deleteTaskEmployeeTask() {
		// TODO: JUnit - Populate test inputs for operation: deleteTaskEmployeeTask 
		Integer taskemployee_id = 0;
		Integer related_task_id = 0;
		TaskEmployee response = null;
		response = service.deleteTaskEmployeeTask(taskemployee_id, related_task_id);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteTaskEmployeeTask
	}

	/**
	 * Operation Unit Test
	* Delete an existing Employee entity
	* 
	 */
	@Test
	public void deleteTaskEmployeeEmployee() {
		// TODO: JUnit - Populate test inputs for operation: deleteTaskEmployeeEmployee 
		Integer taskemployee_id_1 = 0;
		Integer related_employee_id = 0;
		TaskEmployee response = null;
		response = service.deleteTaskEmployeeEmployee(taskemployee_id_1, related_employee_id);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteTaskEmployeeEmployee
	}

	/**
	 * Autowired to set the Spring application context.
	 *
	 */
	@Autowired
	public void setContext(ApplicationContext context) {
		this.context = context;
		((DefaultListableBeanFactory) context.getAutowireCapableBeanFactory()).registerScope("session", new SessionScope());
		((DefaultListableBeanFactory) context.getAutowireCapableBeanFactory()).registerScope("request", new RequestScope());
	}

	/**
	 * Sets Up the Request context
	 *
	 */
	private void setupRequestContext() {
		MockHttpServletRequest request = new MockHttpServletRequest();
		ServletRequestAttributes attributes = new ServletRequestAttributes(request);
		RequestContextHolder.setRequestAttributes(attributes);
	}
}
